// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=2571
// Very easy!

//#define COMPILE_P2571
#ifdef COMPILE_P2571

#include <fstream>

using namespace std;


int main() {
	int a, b, c, d;
	ifstream in("input.txt");
	in >> a >> b >> c;
	in >> d;
	in.close();

	c += d;
	b += c / 60;
	c %= 60;
	a += b / 60;
	b %= 60;
	a %= 24;

	ofstream out("output.txt");

	out << a << " " << b << " " << c << endl;
	out.close();
	return 0;
}

#endif
